<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
	<!-- 自定义的数据源，可以使用下面使用服务器数据源代替 -->	
	<!--
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
        	<value>${jdbc.driverClassName}</value>
        </property>
        <property name="url">
        	<value>${jdbc.url}</value>
        </property>
        <property name="username">
        	<value>${jdbc.username}</value>
        </property>
        <property name="password">
        	<value>${jdbc.password}</value>
        </property>
    </bean>
	--> 
    <!-- 通过 JNDI 使用应用服务器的Connection Pool-->

	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
	     <property name="jndiName">
	     	<value>${jndi.default_name}${oa_application.datacenter}</value>
	     </property>
	</bean>
	
	
	   <!-- linlian 2012-1-31 配置WEBIM独立数据源 ,通过 JNDI 使用应用服务器的Connection Pool-->
	<bean id="webimDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
	     <property name="jndiName">
	     	<value>${jndi.webim_name}${oa_application.datacenter}</value>
	     </property>
	</bean>
	
	
	
	
  
    <!-- 用p6spy 在console显示变量绑定后的真实sql 与ResultSet,方便开发 -->
    <!-- 
    <bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource">
		<constructor-arg>
			<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		        <property name="driverClassName">
		        	<value>${jdbc.driverClassName}</value>
		        </property>
		        <property name="url">
		        	<value>${jdbc.url}</value>
		        </property>
		        <property name="username">
		        	<value>${jdbc.username}</value>
		        </property>
		        <property name="password">
		        	<value>${jdbc.password}</value>
		        </property>
			</bean>
		</constructor-arg>
	</bean>
	-->

    <!-- jdbcTemplate -->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
        	<ref local="dataSource"/>
        </property>
    </bean>
    
    <!-- EAS JDBC 定义开始 -->
    <!-- 
    <bean id="easDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
        	<value>${jdbc.driverClassName}</value>
        </property>
        <property name="url">
        	<value>${jdbc.url}</value>
        </property>
        <property name="username">
        	<value>${jdbc.username}</value>
        </property>
        <property name="password">
        	<value>${jdbc.password}</value>
        </property>
    </bean>    
    -->
    
    <!-- 通过 JNDI 使用应用服务器的Connection Pool-->
	<bean id="easDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
	     <property name="jndiName">
	     	<value>${jndi.eas_name}${oa_application.datacenter}</value>
	     </property>
	</bean>
	    
    <bean id="easJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
        	<ref local="easDataSource"/>
        </property>
    </bean>
    <!-- EAS JDBC 定义结束 -->
	
	<!-- 档案 JDBC 定义开始 -->
	<!-- 
	<bean id="archiveDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
	     <property name="jndiName">
	     	<value>${jndi.archive_name}</value>
	     </property>
	</bean>
	    
    <bean id="archiveJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
        	<ref local="archiveDataSource"/>
        </property>
    </bean>
    -->
	<!-- 档案 JDBC 定义结束 -->
	
	<!-- 公文交换 JDBC 定义开始 -->
	<!--
	<bean id="gwjhDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
	     <property name="jndiName">
	     	<value>${jndi.gwjh_name}</value>
	     </property>
	</bean>
	    
    <bean id="gwjhJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
        	<ref local="gwjhDataSource"/>
        </property>
    </bean>
 	-->
	<!-- 公文交换 JDBC 定义结束 -->
	
    <!-- 记录修改历史的PostUpdate事件侦听器 -->
    <bean id="historyListener" class="org.springside.core.commons.support.HistoryEventListener"/>

    <!--Hibernate SessionFatory-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
        	<ref local="dataSource"/>
        </property>
        <property name="eventListeners">
            <map>
                <entry key="post-update">
                    <ref local="historyListener"/>
                </entry>
            </map>
        </property>

        <property name="mappingDirectoryLocations">
            <list>
                <value>file:${oa_application.config}/org/springside/modules/security/domain/hbm/</value>			
                <value>file:${oa_application.config}/cn/firstsoft/modules/</value>		
                 <value>file:${oa_application.config}/extend/hbm/</value>    	
                <!-- 项目扩展的hbm所放的地方，标准版保持目录为空
                <value>file:${oa_application.config}/extend/hbm/</value>
                 -->
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.connection.SetBigStringTryClob">${hibernate.connection.SetBigStringTryClob}</prop>
            </props>
        </property>
    </bean>
    
    
     <!-- linlian 2012-1-31 配置WEBIM sessionFactory -->
    <bean id="webimSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
        	<ref local="webimDataSource"/>
        </property>
        <property name="eventListeners">
            <map>
                <entry key="post-update">
                    <ref local="historyListener"/>
                </entry>
            </map>
        </property>

        <property name="mappingDirectoryLocations">
            <list>
               <value>file:${oa_application.config}/cn/firstsoft/modules/webim/domain/hbm/</value>    
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect.webim}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.connection.SetBigStringTryClob">${hibernate.connection.SetBigStringTryClob}</prop>
            </props>
        </property>
    </bean>
    
    
    

    <!--Hibernate TransactionManager-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
        	<ref local="sessionFactory"/>
        </property>
    </bean>
    
    
       <!-- linlian 2012-1-31 配置WEBIM TransactionManager-->
    <bean id="webimTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
        	<ref local="webimSessionFactory"/>
        </property>
    </bean>
    
    
    
</beans>
